#!/usr/bin/env bash
set -e

if [ "$EUID" -ne "0" ]; then
    echo "This script must be run as root." >&2
    exit 1
fi

#if (dpkg -s "puppet" >/dev/null 2>&1); then
pkg=puppet
#dpkg --get-selections | grep -q "^puppet[[:space:]]*install$" >/dev/null
if dpkg --get-selections | grep -q "^$pkg[[:space:]]*install$" >/dev/null; then
    echo "puppet is installed."
else
    echo "puppet is not installed."
	wget https://apt.puppetlabs.com/puppetlabs-release-precise.deb
	dpkg -i puppetlabs-release-precise.deb
	apt-get update
    apt-get install --trivial-only puppet
fi
#gem install -r --no-rdoc --no-ri hiera hiera-puppet
